home *** CD-ROM | disk | FTP | other *** search
Wrap
function drawGame() { rpmMeter.gotoAndStop(Math.round(rpm / 600) + 1); nosMeter.gotoAndStop(nos / 100); knobMovie.gotoAndStop(gear + 1); x = 1; while(x < 21) { tracks[x]._x = position * -12 + 349 * (x - 1); x++; } sixtyFtMarker._x = 373.25 + position * -12; threeThirtyMarker._x = 1408 + position * -12; eightMarker._x = 2680 + position * -12; quarterMileMarker._x = 5210 + position * -12; startLine._x = 148 + position * -12; car._x = position / 2 + 88; car.rims._rotation = position * 30; car.rims2._rotation = position * 30; car.rimBlur._alpha = mph; car.rimBlur2._alpha = mph; cityBlur._x = position * -2 + 225; notBlur._x = position * -2 + 225; cityBlur._alpha = mph; car.carBlur._alpha = mph - 60; if(gasPosition == "DOWN") { gasPedal.gotoAndStop(2); } else { gasPedal.gotoAndStop(1); } if(nosDown) { if(0 < nos) { car.nosFlame._visible = true; } else { car.nosFlame._visible = false; } } else { car.nosFlame._visible = false; } if(timeInit.raceTime) { bgBlur._alpha = 0; } else { bgBlur._alpha = mph; } if(100 < position) { bgMovie.gotoAndStop(2); } if(200 < position) { bgMovie.gotoAndStop(3); } if(300 < position) { bgMovie.gotoAndStop(4); } } function doSound() { if(6000 < runningSound.position) { runningSound.stop(); runningSound.start(); } if(gasPosition == "DOWN" and position == 0 and revUpSoundPlaying == false) { revDownSound.stop(); revUpSound.stop(); revUpsound.start(); revUpSoundPlaying = true; } if(revUpSound.position == 1600 or gasPosition == "UP") { revUpSoundPlaying = false; } if(gasPosition == "UP" and position == 0 and revDownSoundPlaying == false) { revUpSound.stop(); revDownSound.stop(); revDownsound.start(); revDownSoundPlaying = true; } if(revDownSound.position == 1600 or gasPosition == "DOWN") { revDownSoundPlaying = false; } if(0 < position) { revDownSound.stop(); revUpSound.stop(); } if(0 < position && burnOutSoundPlaying == false) { burnOutSound.start(); burnOutSoundPlaying = true; } if(0 < burnOutSound.position) { burnOutSound.setVolume -= 1; } runningSound.setVolume(rpm / 60); } function doScore() { x = 0; while(dataHandler.dbRows >= x) { bestTimes["name" + x] = dataHandler["name" + x]; bestTimes["hiScore" + x] = dataHandler["hiScore" + x]; if(dataHandler["hiScore" + x] >= timeInit.raceTime) { if(dataHandler["hiScore" + highestScore] < dataHandler["hiScore" + x]) { highestScore = x; } } x++; } scoreMovie.hiScore1 = dataHandler.hiScore1; scoreMovie.name1 = dataHandler.name1; hiScoreRow = dataHandler["id" + highestScore]; hiScoreTime = dataHandler["hiScore" + highestScore]; } function deInit() { emailPrompt = "ENTER EMAIL ADDRESS"; greenLight = false; bg2.gotoAndPlay(2); mph = 0; car.nosFlame._visible = false; if(timeInit.raceTime < hiScoreTime) { topTen.gotoAndPlay(2); } else { topHundred.gotoAndPlay(2); } glowMovie.gotoAndPlay(2); } function getInput() { if(Key.isDown(66)) { brakesForce = -10000; } else { brakesForce = 0; } if(Key.isDown(32)) { gasPosition = "DOWN"; } else { gasPosition = "UP"; } if(canGear && Key.isDown(40) && gear < 6 && greenLight) { gear++; rpm = wheelRate * gearRatio[gear] * differential * 60 / 2 / 3.14; runningSound.stop(); runningSound.start(1,0); } if(canGear && Key.isDown(38) && 0 < gear && greenLight) { gear--; rpm = wheelRate * gearRatio[gear] * differential * 60 / 2 / 3.14; } if(Key.isDown(40) || Key.isDown(38)) { canGear = false; } else { canGear = true; } if(Key.isDown(78) && greenLight) { nosDown = true; } else { nosDown = false; } } function gameClock() { timeMilliseconds = getTimer() - startTime; } function initGame() { burnOutSoundPlaying = false; revUpSound.setVolume(60); revDownSound.setVolume(60); runningSound.stop(); emailPrompt = "ENTER EMAIL ADDRESS"; glowMovie.gotoAndStop(1); if(rules.animating == true) { rules.gotoAndPlay(11); } bgMovie.gotoAndStop(2); bgBlur._alpha = 0; car.nosFlame._visible = false; car.carBlur._alpha = 0; cityBlur._alpha = 0; hiScoreFlag = false; scoreWindow.gotoAndPlay(1); bg2.gotoAndStop(1); greenLight = false; timeInit.gotoAndStop(1); timeInit._visible = true; startTime = getTimer(); timeFormatted = 0; timeMilliseconds = 0; velocity = 0; acceleration = 0; rpm = 0; mph = 0; brakesForce = 0; timeInit.raceTime = 0; position = 0; gear = 0; raceTimer._visible = false; car._x = position + 88; car.rimBlur._alpha = 0; bg2.trapSpeed = 0; bg2.sixtyftTime = 0; bg2.threethirtyTime = 0; bg2.eigthMileTime = 0; bg2.quarterMileTime = 0; nos = 1600; drawGame(); thisGameScore = 100; } function doPhysics() { wheelRate = velocity / wheelRadius; gas(); torque = torqueCurve[Math.round(rpm / 100)] - torqueCurve[Math.round(rpm / 100)] * 0.3; if(gasPosition == "DOWN") { driveForce = torque * gearRatio[gear] * differential * (transEff / wheelRadius); } else { driveForce = 0; } cDrag = 0.5 * cRSXdrag * frontalArea * airDensity; dragForce = -1 * cDrag * velocity; cRR = cDrag * 30; rrForce = -1 * cRR * velocity; totalForce = driveForce + rrForce + dragForce + brakesForce; if(nosDown == true) { totalForce += nos / deltaTime; if(0 < nos) { nos -= 10; } } acceleration = totalForce / (carWeight + 100); if(0 >= brakesForce && velocity < 0) { velocity = 0; } velocity += deltaTime * acceleration / 12; position += deltaTime * velocity / 32; } function gas() { if(gasPosition == "UP" && 0 < rpm) { if(gear != 0) { rpm = wheelRate * gearRatio[gear] * differential * 60 / 2 / 3.14; } else { rpm -= 600 * deltaTime; } } if(gasPosition == "DOWN") { var _loc1_ = null; var _loc0_ = null; if(!(typeof (_loc0_ = gear) != typeof (_loc1_ = 0) ? false : _loc0_ == _loc1_)) { if(!(typeof (_loc0_ = gear) != typeof (_loc1_ = 1) ? false : _loc0_ == _loc1_)) { if(!(typeof (_loc0_ = gear) != typeof (_loc1_ = 2) ? false : _loc0_ == _loc1_)) { if(!(typeof (_loc0_ = gear) != typeof (_loc1_ = 3) ? false : _loc0_ == _loc1_)) { if(!(typeof (_loc0_ = gear) != typeof (_loc1_ = 4) ? false : _loc0_ == _loc1_)) { if(!(typeof (_loc0_ = gear) != typeof (_loc1_ = 5) ? false : _loc0_ == _loc1_)) { if(!(typeof (_loc0_ = gear) != typeof (_loc1_ = 6) ? false : _loc0_ == _loc1_)) { rpm += 50 * deltaTime; } else { rpm += 20 * deltaTime; } } else { rpm += 30 * deltaTime; } } else { rpm += 40 * deltaTime; } } else { rpm += 62 * deltaTime; } } else { rpm += 85 * deltaTime; } } else { rpm += 150 * deltaTime; } } else if(7200 < rpm) { rpm -= 1200 * deltaTime; } else { rpm += 600 * deltaTime; } } if(rpm < 0) { rpm = 0; } } function formatText() { mph = velocity * 3600 / 1609.344; mph = Math.round(mph); position = Math.round(position * 100) / 100; acceleration = Math.round(acceleration * 100) / 100; displacement = Math.round(displacement * 100) / 100; velocity = Math.round(velocity * 100) / 100; driveForce = Math.round(driveForce * 100) / 100; } function mainEntry() { gameClock(); timeFormatted = timeMilliseconds / 1000; if(greenLight && position == 0) { timeInit._visible = false; } if(18.288 < position && !bg2.sixtyftTime) { bg2.sixtyftTime = timeFormatted; car.time = timeFormatted; } if(100.584 < position && !bg2.threethirtyTime) { bg2.threethirtyTime = timeFormatted; car.time = timeFormatted; } if(201.168 < position && !bg2.eigthMileTime) { bg2.eigthMileTime = timeFormatted; car.time = timeFormatted; } if(402.366 < position) { if(!timeInit.raceTime) { timeInit._visible = true; timeInit.gotoAndStop(2); timeInit.raceTime = timeFormatted; bg2.trapSpeed = mph; raceTimer._visible = true; bg2.quarterMileTime = timeFormatted; car.time = timeFormatted; thisGameScore = timeFormatted; _root.finishSound.start(0,1); _root.runningSound.stop(); } brakesForce = -10000; if(0 < rpm) { rpm -= 200; } if(mph < 5) { gotoAndPlay(6); rpm = 0; mph = 0; car.rims._rotation = 90; car.rims2._rotation = 90; } } else { getInput(); } if(30 < timeFormatted) { gotoAndPlay(2); welcomeScreen.gotoAndStop(1); } doPhysics(); formatText(); drawGame(); doSound(); } torqueCurve = new Array(0,0,6.8,6.8,13.6,20.4,27.2,33.9,40.7,47.5,54.3,61.1,67.8,74.6,81.4,88.2,95,101.7,108.5,115.3,128.9,135.6,153.3,156,162.8,166.8,169.5,173.6,179,183.1,185.8,189.9,194,196.7,199.4,203.4,206.2,210.2,217,223.8,230.6,237.3,244.1,250.9,257.7,272.6,257.7,250.9,244.1,237.3,240.1,240.1,240.1,238.7,238.7,238.7,241.4,244.1,248.2,250.9,253.6,256.3,259,260.4,261.8,264.5,263.1,261.8,260.4,259,257.7,256.3,255,253.6,253.6,253.6,244.1,242.8,237.3,233.3,230.1,225,215.2,205.2,195.2,185.2,165.2,155.2,145.2,135.2,125.2,115.2,95.2,85.2,75.2,65.2,55.2); carWeight = 1260; differential = 4.389; wheelRadius = 0.4064; transEff = 0.7; frontalArea = 2.2; cRSXDrag = 0.3; gearRatio = new Array(0,3.267,2.13,1.517,1.147,0.921,0.738); canGear = true; mph = 0; timeMilliseconds = 0; position = 0; acceleration = 0; timeFormatted = 0; displacement = 0; startTime = 0; deltaTime = 0; timeInit.raceTime = 0; velocity = 0; rpm = 0; angular_velocity = 0; gear = 0; driveForce = 0; torque = 0; gearRatioDebug = 0; airDensity = 1.29; gasPosition; wheelRate = 0; bg2.trapSpeed = 0; bg2.sixtyftTime = 0; bg2.threethirtyTime = 0; bg2.eigthMileTime = 0; bg2.quarterMileTime = 0; nos = 1600; nosDown = false; thisGameScore = 100; hiScoreFlag = false; runningSound = new Sound(runningSoundMC); runningSound.attachSound("runningSound"); finishSound = new Sound(finishSoundMC); finishSound.attachSound("finishSound"); revUpSound = new Sound(revUpMC); revUpSound.attachSound("revUpSound"); revDownSound = new Sound(revDownMC); revDownSound.attachSound("revDownSound"); burnOutSound = new Sound(burnOutMC); burnOutSound.attachSound("burnOut"); revUpSoundPlaying = false; revDownSoundPlaying = true; burnOutSoundPlaying = false; initGame(); stop();